package com.ncdnapp.core.tracer;

import java.util.concurrent.Executor;

public class TraceExecutor implements Executor {
    private final Executor delegate;
    private String poolName;

    public TraceExecutor(String poolName, Executor delegate) {
        this.delegate = delegate;
        this.poolName = poolName;
    }

    @Override
    public void execute(Runnable command) {
        TraceThread traceThread = new TraceThread(command);
        traceThread.setName(this.poolName + "-" + traceThread.getId());
        delegate.execute(traceThread);
    }
}
